package com.hengpeng.itfints.constants;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hengpeng.common.cis.ComponentContextLoader;
import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.itfinbase.constants.SystemConfigConstants;
import com.hengpeng.itfinbase.persist.Partner;
import com.hengpeng.itfinbase.persist.Partner.PartnerType;
import com.hengpeng.itfints.service.ServiceFactory;

public class PartnerUtil
{
	private final static Log logger = LogFactory.getLog(SystemConfigUtil.class);

	private static ServiceFactory configService = ComponentContextLoader.getBean(ServiceFactory.class);

	public static boolean isTrustPattern()
	{
		DynamicQuery query = new DynamicQuery(Partner.class);
		query.eq("id", SystemConfigUtil.getConfigValue(SystemConfigConstants.PARTNER_ID));
		Partner partner=configService.getPersistService().getEntity(query, Partner.class);
		if (partner != null && !partner.getPartnerType().equals(PartnerType.FUND))
		{
			return true;
		}else{
			return false;
		}
	}
	
	public static PartnerType getPartnerType()
	{
		DynamicQuery query = new DynamicQuery(Partner.class);
		query.eq("id", SystemConfigConstants.PARTNER_ID);
		Partner partner=configService.getPersistService().getEntity(query, Partner.class);
		return partner.getPartnerType();
	}
}
